package io.renren.modules.sys.service.impl;

import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.entity.UsersEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.AgentShopBusDao;
import io.renren.modules.sys.entity.AgentShopBusEntity;
import io.renren.modules.sys.service.AgentShopBusService;


@Service("agentShopBusService")
public class AgentShopBusServiceImpl extends ServiceImpl<AgentShopBusDao, AgentShopBusEntity> implements AgentShopBusService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String busParent = (String) params.get("busParent");
        String busName = (String)params.get("busName");
        String busPhone = (String)params.get("busPhone");
        IPage<AgentShopBusEntity> page = this.page(
                new Query<AgentShopBusEntity>().getPage(params),
                new QueryWrapper<AgentShopBusEntity>()
                .like(StringUtils.isNotBlank(busParent),"BUS_PARENT", busParent)
                .like(StringUtils.isNotBlank(busName), "BUS_NAME" , busName)
                .like(StringUtils.isNotBlank(busPhone), "BUS_PHONE" ,busPhone)
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils queryUsers(Map<String, Object> params) {
        IPage<AgentShopBusEntity> page = this.page(
                new Query<AgentShopBusEntity>().getPage(params),
                new QueryWrapper<AgentShopBusEntity>()
        );
        return new PageUtils(page);
    }

    @Override
    public int queryLineCodeNum(Integer userid){
        int num = baseMapper.queryLineCodeNum(userid);
        return num;
    }
}
